package com.itheima.mapper;

import com.itheima.dto.EmpDto;
import com.itheima.dto.EmpLoginDto;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

   /* @Select("select * from emp limit #{strat},#{pageSize}")
    public List<Emp> getByPage(@Param("strat") Integer start, @Param("pageSize") Integer pageSize);

    @Select("select count(*) from emp")
    public Long getTotal();*/

    @Select("select * from emp order by desc ")
    public List<Emp> getEByPage();

    List<Emp> getByPage(EmpDto empDto);

    int delByIds(@Param("ids") Integer[] ids);

    @Insert("insert into emp values (null,#{username},#{password},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    int insertEmp(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp getById(Integer id);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp findByUsernameAndPassword(EmpLoginDto dto);


    @Delete("delete from emp where dept_id = #{deptId}")
    int delByDeptId(Integer deptId);

}
